<template>
	<view class="container">
		<view class="search-bar">
			<view class="search-bar-form">
				<view class="search-bar-box">
					<icon class="icon-search-in-box" type="search" size="16"></icon>
					<input confirm-type="search" class="search-bar-input" placeholder="联系人/手机号" placeholder-class="phcolor"
					 :value="inputVal" :focus="inputShowed" @input="inputTyping" @confirm="searchend" />
					<view class="icon-clear" v-if="inputVal" @tap="clearInput">
						<!-- #ifdef APP-PLUS || MP -->
						<icon type="clear" :size="15"></icon>
						<!-- #endif -->
						<!-- #ifdef H5 -->
						<tui-icon name="close-fill" :size="16" color="#bfbfbf"></tui-icon>
						<!-- #endif -->
					</view>
				</view>
			</view>
		</view>
		<view class="header flex flex-align flex-bt">
			<view class="">社区用户</view>
			<view class="">{{type==1?'待核销订单':type==4?'':'观看时长'}}</view>
		</view>
		<view class="shequList">
			<view class="list flex flex-align flex-bt" v-for="(item,index) in dataList" :key="index" v-if="dataList.length!=0" @click="goUrl(item)">
				<view class="left flex flex-align">
					<image :src="item.headimg" mode=""></image>
					<view class="name">
						<view class="">昵称:{{item.nickname}}</view>
						<view class="" style="margin-top: 6rpx;" v-if="status==2">所属团长:{{item.community_user_name}}</view>
						<view class="tel flex flex-align" @click="bohao(item.phone)">
							<text class="cuIcon-phone cuIcon" style="color: #f20;font-size: 30rpx;margin-right: 10rpx;"></text>
							<!-- <tui-icon name="tel" color="#f20" :size="24"></tui-icon> -->
							<view class="">{{item.phone||'暂无'}}</view>
						</view>
					</view>
				</view>
				<view class="right flex flex-align" v-if="type==1">
					<view class="">{{item.order_count}} 个</view>
					<tui-icon name="arrowright" color="#999" :size="24"></tui-icon>
				</view>
				<view class="right flex flex-align" v-if="type==2">
					<view class="">{{tui.secondsToTime(item.yesterday_look_time)}}</view>
				</view>
				<view class="right flex flex-align" v-if="type==3">
					<view class="">{{tui.secondsToTime(item.today_look_time)}}</view>
				</view>
				<view class="right flex flex-align" v-if="type==4">
					<view class="" style="background: #f20;color: #fff;padding: 6rpx 10rpx;font-size: 24rpx;border-radius: 6rpx;" @click="submite(item)">{{item.is_auditor?'取消核销员':'设置核销员'}}</view>
				</view>
			</view>
			
		</view>
		<view class="empty-box" v-if="dataList.length==0">
			<image src="/static/ic_nodata.png" mode=""></image>
			<view class="">暂无数据</view>
		</view>
		<DialogBox ref="DialogBox"></DialogBox>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				dataList:[],
				page:1,
				inputShowed:false,
				inputVal:'',
				type:'',
				quhuoImg:'',
				status:''
			}
		},
		onLoad(e) {
			console.log(e)
			this.type= e.type
			this.status =e.status
			uni.setNavigationBarTitle({
				title: e.type==1?'社区用户':e.type==2?'昨日观看人数':e.type==3?'今日观看人数':'我的团队'
			})
			this.getData()
		},
		
		onReachBottom() {
			this.page++
			this.getData()
		},
		
		methods: {
			getData(){
				let that = this
				that.tui.request(that.type==1?'api.auth.live/communityUserLista':that.type==2?'api.auth.live/communityUserListb':that.type==3?'api.auth.live/communityUserListc':"api.auth.live/communityUserList", "POST", {page:that.page,keyword:that.inputVal}, false, false, true).then((res) => {
					console.log(res)
					if(res.code==1){
						that.dataList = that.dataList.concat(res.data.list)
					}
				}).catch((res) => {
				
				})
			},
			submite(e){
				let that = this
				that.$refs['DialogBox'].confirm({
					title: '提示',
					content: e.is_auditor?'是否取消此人的核销员':'是否设置此人为核销员',
					DialogType: 'inquiry',
					animation: 0
				}).then(() => {
					that.tui.request('api.auth.live/setAuditor', "POST", {auditor_uuid:e.id,type:e.is_auditor?2:1}, false, false, true).then((res) => {
						console.log(res)
						that.tui.toast(res.info)
						if(res.code==1){
							setTimeout(function(){
								that.page=1
								that.dataList=[]
								that.getData()
							},1000)
						}
					}).catch((res) => {
					
					})
				})
				
			},
			goUrl(e){
				if(this.type==1){
					this.tui.href('/pages/hexiaoList/hexiaoList?type=2&uuid='+e.id)
				}
			},
			searchend(){
				this.page=1
				this.dataList = []
				this.getData()
			},
			bohao(e){
				if(e){
					uni.makePhoneCall({
						phoneNumber:e
					});
				}
			},
			inputTyping(e) {
				this.inputVal = e.detail.value;
			},
			clearInput() {
				this.inputVal = "";
				this.inputShowed = false;
				uni.hideKeyboard() //强行隐藏键盘
				this.searchend()
			},
			
		},
	}
</script>

<style lang="scss">
	page {
		background: #f6f6f6;
	}
	.header{padding: 30rpx;}
	.search-bar {
		display: flex;
		align-items: center;
		position: relative;
		padding: 27rpx 30rpx 35rpx;
		background-color: #fff;
	}
	
	.search-bar-form {
		flex: 1;
		position: relative;
		border-radius: 32rpx;
		background: #f2f5f7;
	}
	
	.search-bar-box {
		display: flex;
		align-items: center;
		position: relative;
		padding-left: 20rpx;
		padding-right: 20rpx;
		height: 64rpx;
		z-index: 1;
		input{font-size: 26rpx;}
	}
	
	.search-bar-input {
		line-height: normal;
		width: 100%;
		padding-left: 20rpx;
		font-size: 30rpx;
		color: #333;
	}
	.shequList{background: #fff;
		.list{border-bottom: 1px solid #eee;padding: 20rpx;
			.left{
				image{width: 80rpx;height: 80rpx;border-radius: 10rpx;margin-right: 10rpx;}
				.name{
					.tel{margin-top: 10rpx;
						view{font-size: 24rpx;}
					}
				}
			}
		}
	}
</style>